package models

import (
	"github.com/astaxie/beego/orm"
)

type Target struct {
	Id             int64
	TrgId          string `orm:"size(10);index"`
	UniprotKb      string `orm:"size(20);index"`
	TrgName        string `orm:"size(256);"`
	ShortName      string `orm:"size(50);"`
	Organism       string `orm:"size(50)"`
	Gene           string `orm:"size(20)"`
	HgncId         string `orm:"size(20);index"` //HUGO Gene Nomenclature Committee ID
	Classification string `orm:"size(256)"`
	Belong         string `orm:"size(256)"`
	TarImg         string `orm:"size(20)"`
	ProSynonyms    string `orm:"type(text);null"`
	GeneSynonyms   string `orm:"size(256)"`
	Function       string `orm:"type(text);null"`
	FastaFile      string `orm:"size(20)"`
	Domain         string `orm:"size(256);null"`
	Region         string `orm:"size(256);null"`
	Repeat         string `orm:"type(text);null"`
	RelationId     string `orm:"type(text);null"`
	PdbsZipfile    string `orm:"size(50)"`
	Length         int64
	MolsZipfile    string `orm:"size(50)"`
}

func (m *Target) TableName() string {
	return "target"
}

func (m *Target) Insert() error {
	if _, err := orm.NewOrm().Insert(m); err != nil {
		return err
	}
	return nil
}

func (m *Target) Read(fields ...string) error {
	if err := orm.NewOrm().Read(m, fields...); err != nil {
		return err
	}
	return nil
}

func (m *Target) Update(fields ...string) error {
	if _, err := orm.NewOrm().Update(m, fields...); err != nil {
		return err
	}
	return nil
}

func (m *Target) Delete() error {
	if _, err := orm.NewOrm().Delete(m); err != nil {
		return err
	}
	return nil
}

func (m *Target) Query() orm.QuerySeter {
	return orm.NewOrm().QueryTable(m)
}
